<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-cascades"></i> 订单列表
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <el-button type="primary" icon="el-icon-search" @click="handleAddDetails">添加</el-button>
            <el-table
                    :data="orderDetailsData"
                    border
                    class="table"
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                    @selection-change="handleSelectionChange"
            >
                <el-table-column prop="Order_details_id" label="订单细则编号" width="120" align="center"></el-table-column>
                <el-table-column prop="Order_id" label="订单编号" width="100" align="center"></el-table-column>
                <el-table-column prop="Goods_id" label="商品编号" width="100" align="center"></el-table-column>
                <el-table-column prop="Ordgoods_number" label="购买数量" align="center"></el-table-column>
                <el-table-column prop="Factory_id" label="厂家编号" align="center"></el-table-column>
                <el-table-column prop="Order_sum_money" label="总金额" align="center"></el-table-column>

            </el-table>
        </div>

<!--         添加弹出框-->
                <el-dialog title="细则信息" v-model="detailVisible" width="30%">
                    <el-form ref="form" :model="form" label-width="70px">
                        <el-form-item label="细则编号">
                            <el-input v-model="tempdetailData.Order_details_id"></el-input>
                        </el-form-item>
                        <el-form-item label="订单编号">
                            <el-input v-model="tempdetailData.Order_id"></el-input>
                        </el-form-item>
                        <el-form-item label="商品编号">
                            <el-input v-model="tempdetailData.Goods_id"></el-input>
                        </el-form-item>
                        <el-form-item label="购买数量">
                            <el-input v-model="tempdetailData.Ordgoods_number"></el-input>
                        </el-form-item>
                        <el-form-item label="厂家编号">
                            <el-input v-model="tempdetailData.Factory_id"></el-input>
                        </el-form-item>
                        <el-form-item label="总金额">
                            <el-input v-model="tempdetailData.Order_sum_money"></el-input>
                        </el-form-item>
                    </el-form>
                    <template #footer>
                        <span class="dialog-footer">
                            <el-button @click="detailVisible = false">取 消</el-button>
                            <el-button type="primary" @click="AddDetails">确 定</el-button>
                        </span>
                    </template>
                </el-dialog>
    </div>
</template>

<script>
    import {adddetails, fetchorderdetailData} from "../api/index";
    export default {
        name: "goodsData",
        data() {
            return {
                orderDetailsData: [],
                tempdetailData: {},
                query:{},
                multipleSelection: [],
                delList: [],
                detailVisible: false,
                pageTotal: 0,

                idx: -1,
                id: -1
            };
        },
        created() {
            this.getData()
        },
        methods: {

            getData(){
                fetchorderdetailData().then(res =>{console.info(res)
                    this.orderDetailsData=res.data.value
                })
            },

            handleAddDetails(){
                this.detailVisible = true;
            },
            AddDetails() {
                this.detailVisible = false;
                this.$message.success(`添加成功`);
                adddetails(this.tempdetailData).then(res =>{console.info(res)
                    console.log(this.tempdetailData)
                    console.log(res)
                    window.location.reload()
                })
            },

        }
    };
</script>

<style scoped>
    .handle-box {
        margin-bottom: 20px;
    }

    .handle-select {
        width: 120px;
    }

    .handle-input {
        width: 300px;
        display: inline-block;
    }
    .table {
        width: 100%;
        font-size: 14px;
    }
    .red {
        color: #ff0000;
    }
    .mr10 {
        margin-right: 10px;
    }
    .table-td-thumb {
        display: block;
        margin: auto;
        width: 40px;
        height: 40px;
    }
</style>
